package com.example.JcGQS.controller;

import com.example.JcGQS.pojo.dto.PageADTO;
import com.example.JcGQS.pojo.dto.PageDTO;
import com.example.JcGQS.pojo.vo.ApplicantToSubmitVo;
import com.example.JcGQS.pojo.vo.AuditReviewedingVo;
import com.example.JcGQS.pojo.vo.DataRecordVo;
import com.example.JcGQS.pojo.vo.PurchaseVo;
import com.example.JcGQS.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 采购列表控制器
 *
 * @author 末日
 * @data 2023/11/10
 */
@RestController
@RequestMapping("/GQS/purchase/list")
public class PurchaseListController {
    @Autowired
    PurchaseService purchaseService;

    /**
     * 根据申购人查询(审核中/已下单/采购中/采购完成)采购信息
     *
     * @return
     */
    @PostMapping("/applicant/revieweding")
    public DataRecordVo<PurchaseVo> applicantReviewedingPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
       return purchaseService.applicantReviewedingPurchase(pageDTO, token);

    }

    /**
     * 根据申购人查询(采购失败并删除/审核失败并删除)采购信息
     *
     * @return
     */
    @PostMapping("/applicant/delete")
    public DataRecordVo<PurchaseVo> applicantDeletePurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
       return purchaseService.applicantDeletePurchase(pageDTO, token);
    }

    /**
     * 根据申购人查询(待提交)采购信息
     *
     * @return
     */
    @PostMapping("/applicant/toSubmit")
    public  DataRecordVo<ApplicantToSubmitVo> applicantToSubmitPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
       return purchaseService.applicantToSubmitPurchase(pageDTO, token);
    }

    /**
     * 根据申购人查询(采购失败/审核失败)采购信息
     *
     * @return
     */
    @PostMapping("/applicant/toSubmit/lose")
    public  DataRecordVo<ApplicantToSubmitVo> applicantToSubmitPurchaseLose(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        return purchaseService.applicantToSubmitPurchaseLose(pageDTO, token);
    }
    /**
     * 根据审核人查询(审核中)采购信息
     *
     * @return
     */
    @PostMapping("/audit/revieweding")
    public DataRecordVo<AuditReviewedingVo> auditReviewedingPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        return purchaseService.auditReviewedingPurchase(pageDTO, token);
    }

    /**
     * 根据审核人查询(审核失败/采购中/已下单/采购完成/采购失败/采购失败并删除/审核失败并删除)采购信息
     *
     * @return
     */
    @PostMapping("/audit/underPurchase")
    public DataRecordVo<PurchaseVo> auditUnderPurchasePurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
       return purchaseService.auditUnderPurchasePurchase(pageDTO, token);
    }

    /**
     * 根据采购人来查询(审核中)采购信息
     *
     * @return
     */
    @PostMapping("/buyer/revieweding")
    public DataRecordVo<AuditReviewedingVo> buyerReviewedingPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
      return   purchaseService.buyerReviewedingPurchase(pageDTO, token);
    }

    /**
     * 根据采购人来查询(采购中/已下单)采购信息
     *
     * @return
     */
    @PostMapping("/buyer/underPurchase")
    public DataRecordVo<PurchaseVo> buyerUnderPurchasePurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
      return   purchaseService.buyerUnderPurchasePurchase(pageDTO, token);
    }

    /**
     * 根据采购人来查询(采购完成)采购信息
     *
     * @return
     */
    @PostMapping("/buyer/purchaseCompleted")
    public DataRecordVo<PurchaseVo> buyerPurchaseCompletedPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
      return   purchaseService.buyerPurchaseCompletedPurchase(pageDTO, token);
    }

    /**
     * 根据采购人来查询(采购失败/采购失败并删除)采购信息
     *
     * @return
     */
    @PostMapping("/buyer/purchaseFailed")
    public DataRecordVo<PurchaseVo> buyerPurchaseFailedPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
       return purchaseService.buyerPurchaseFailedPurchase(pageDTO, token);
    }

    /**
     * 根据仓库管理人来查询(已下单)的采购信息
     *
     * @return
     */
    @PostMapping("/warehouseman/haveOrder")
    public DataRecordVo<PurchaseVo> warehousemanHaveOrderPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
      return   purchaseService.warehousemanHaveOrderPurchase(pageDTO, token);
    }

    /**
     * 根据仓库管理人来查询(已下单)的采购信息
     *
     * @return
     */
    @PostMapping("/warehouseman/return")
    public DataRecordVo<PurchaseVo> warehousemanReturnPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        return   purchaseService.warehousemanReturnPurchase(pageDTO, token);
    }
    /**
     * 根据仓库管理人来查询(采购完成)的采购信息
     *
     * @return
     */
    @PostMapping("/warehouseman/purchaseCompleted")
    public DataRecordVo<PurchaseVo> warehousemanPurchaseCompletedPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
      return   purchaseService.warehousemanPurchaseCompletedPurchase(pageDTO, token);
    }

    /**
     * 根据仓库管理人来查询(采购失败/采购失败并删除)的采购信息
     * @return
     */
    @PostMapping("/warehouseman/purchaseFailed")
public DataRecordVo<PurchaseVo> warehousemanPurchaseFailedPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
    String token = request.getHeader("Authorization");
    return   purchaseService.warehousemanPurchaseFailedPurchase(pageDTO, token);
}
    /**
     * 根据采购信息查询所有审核人
     *
     * @return
     */
    @PostMapping("/audit/list")
    public void auditListPurchase(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        purchaseService.auditListPurchase(pageDTO, token);
    }

//    @PostMapping("/a")
//    public DataRecordVo<PurchaseVo> a(@RequestBody PageADTO pageADTO, HttpServletRequest request) {
//        String token = request.getHeader("Authorization");
//       return purchaseService.a(pageADTO, token);
//    }
}
